-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[Header Mode] Elide property initializers #5572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Header Mode] Elide property initializers #5572
Conversation
…olved for header compilation. ^KT-78422
^KT-78422,KT-82336
demiurg906
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the comments above, could you please squash all commits in this branch into one?
They all are about the same thing with a small variations and it's not very practical to have them separated.
OFC fixes to comments would be nice to have in !fixup commits to this big squashed one.
| if (!initializerIsAlreadyResolved) { | ||
| dataFlowAnalyzer.enterProperty(property) | ||
| } | ||
| else if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch is actually useless, as you anyway remove the initializer in the end of the transformProperty.
| else -> if (it.isExpression()) { | ||
| context.calleeNamesForLambda += null | ||
| propertyInitializer = withForcedLocalContext { | ||
| propertyInitializer = withForcedLocalContext(!isReturnType || modifiers?.isConst() == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting forceKeepingTheBodyInHeaderMode here actually doesn't do anything, as this property affects only transformFunctionBody, and here we call just getAsFirExpression, which unconditionally creates an expression.
Here you should just don't call getAsFirExpression if isReturnType && modifiers?.isConst() != true.
https://youtrack.jetbrains.com/issue/KT-78422/
Fixes https://youtrack.jetbrains.com/issue/KT-82336/